﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date, ,>
-- Description:	<Description, ,>
-- =============================================
CREATE FUNCTION ISCURRENT
(
	@Entity1 int,
	@RelationshipName nvarchar(12),
	@Entity2 int,
	@EvalDate datetime=NULL
)
RETURNS bit
AS
BEGIN

	DECLARE @ISINRANGE bit, @STARTDATE datetime, @ENDDATE datetime
	SET @ISINRANGE = 0

	SELECT @STARTDATE=[StartDate], @ENDDATE=[EndDate] FROM EntityRelationships
		WHERE [Entity1ID]=@Entity1 AND [Entity2ID]=@Entity2 AND [ShortRelationshipName]=@RelationshipName

	RETURN dbo.ISDATEINRANGE(@STARTDATE,@ENDDATE,@EvalDate)

END
